
import db
from decorators import cached_property

class IndicatorController(object):

    def __init__(self, id=None, user=None):
        self.id = id
        self.user = user

    @cached_property
    def indicator(self):
        return db.IndicatorTB.get(id=self.id)

    @classmethod
    def get_indicators(cls):
        """获取所有指标"""
        return db.IndicatorTB.find()

    @classmethod
    def create(cls, **args):
        db.IndicatorTB.add(**args)

    def delete(self):
        db.IndicatorTB.rm(id=self.id)

    def update(self, **args):
        db.IndicatorTB.set(**args).where(id=self.id)





